import {Modal} from 'antd'

const confirm = Modal.confirm;

export * from './function'
export * from './mutation-component'
export * from './query-component'
export * from './current-user'
export * from './modal-actions'

export const STATE = {
    'WAIT': '待审核',
    'PASS': '通过',
    'REJECT': '拒绝'
}

export const mobileReg = /^1[3456789]\d{9}$/;
export const emailReg = /^([a-zA-Z0-9_-])+@([a-zA-Z0-9_-])+(.[a-zA-Z0-9_-])+/

export const warning = ({title, content, onOk, onCancel}) => {
    confirm({
        title,
        content,
        onOk() {
            onOk && onOk();
        },
        onCancel() {
            onCancel && onCancel();
        },
    });
}

export const success = ({title, content, onOk}) => Modal.success({
    title, content, onOk() {
        onOk && onOk()
    }
})

export const getStaticUrl = url => (process.env.STATIC_PREFIX_URL || '') + url
